Ext.define('app.system.config.grid', {
	extend : "Ext.grid.Panel",
	frame : false,
	border : false,
	requires : [ 'app.system.model.config', 'app.system.config.form' ],
	initComponent : function() {
		var me = this;
		var me = this;
		var columns = me.createColumns();
		var store = me.createStore();
		var dockitems = new Array();
		var queryarry = me.createQuery(store);
		if (queryarry != null) {
			me.qf = widget.search(queryarry);
			dockitems.push(me.qf);
		}
		var toolarray = me.createTool();
		if (toolarray.length > 0) {
			dockitems.push(widget.toolbar(toolarray));
		}
		dockitems.push(widget.paging(store));
		Ext.apply(me, {
			store : store,
			columns : columns,
			singleExpand : me.singleExpand || true,
			dockedItems : dockitems
		});
		store.load();
		me.callParent(arguments);
	},
	createTool : function() {
		var me = this;
		var array = new Array();
		utils.pushbtnarray(array, {
			text : '编辑',
			handler : function() {
				var rec = utils.single(me);
				if (rec != null) {
					Ext.create('app.system.config.form', {
						parentTarget : me,
						configId : rec.get('configId')
					}).show();
				} else {
					Ext.Msg.alert('提示', '请选择记录');
				}
			}
		});
		return array;
	},
	createQuery : function(store) {
		var me = this;
		var param = {};
		var array = new Array();
		array.push(widget.queryConfig({
			xtype : 'textfield',
			name : 'configName',
			fieldLabel : '配置名称:'
		}));
		array.push(widget.queryConfig({
			xtype : 'textfield',
			name : 'configKey',
			fieldLabel : '配置key:'
		}));
		param['bl'] = 'center';
		param['items'] = array;
		param['ds'] = store;
		var array = new Array();
		param['btn'] = array;
		return param;
	},
	createStore : function() {
		return widget.ds({
			clazz : 'app.system.model.config',
			url : systemUrl + '/boyon/config/query'
		});
	},
	createColumns : function() {
		var array = new Array();
		array.push(widget.column({
			dataIndex : 'configId',
			width : 80,
			text : '配置ID'
		}));
		array.push(widget.column({
			dataIndex : 'configName',
			width : 80,
			text : '配置名称'
		}));
		array.push(widget.column({
			dataIndex : 'configKey',
			width : 120,
			text : '关键字'
		}));
		array.push(widget.column({
			dataIndex : 'configValue',
			width : 120,
			text : '值'
		}));
		return array;
	},
	reloadStore : function() {
		var me = this;
		me.store.reload();
	}
});